package com.woniuxy.thread.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo {
	public static void main(String[] args) {
		// 创建了大小为10的线程池
//		ExecutorService service = Executors.newFixedThreadPool(10);
//		ExecutorService service = Executors.newCachedThreadPool();
		ExecutorService service = Executors.newSingleThreadExecutor();

		for (int i = 0; i < 100; i++) {
			service.execute(() -> {
				System.out.println(Thread.currentThread().getName());
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
		}

	}

}
